/*
 * ControllerAdvice.java
 * Copyright 2020 Qunhe Tech, all rights reserved.
 * Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
 */

package com.lixinlei.tech.ex.handler.advice;

import com.lixinlei.tech.ex.handler.ex.BusinessException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Function: 统一异常处理
 *
 * @author wali
 * @date 2020/11/2
 */
@RestControllerAdvice
public class ControllerAdvice {

    @ExceptionHandler(BusinessException.class)
    public String businessExceptionHandler(BusinessException e) {
        System.out.println("Business Exception Handler");
        return "Business";
    }

//    @ExceptionHandler(RuntimeException.class)
//    public String businessExceptionHandler(RuntimeException e) {
//        System.out.println("Runtime");
//        return "Runtime";
//    }

    @ExceptionHandler(Exception.class)
    public String handle(final Exception e) {
        System.out.println("handler");
        return "Exception";
    }

}
